package com.hwua.app.base;

import android.app.Activity;
import android.app.Fragment;
import android.os.Bundle;
import android.widget.LinearLayout;

import com.hwua.client.R;

/**
 * 片段界面的父类
 */
public abstract class FragmentActivity extends Activity {

    private static final int ROOT_CONTAINER_ID=0x90001;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        //创建线性布局对象
        LinearLayout layout=new LinearLayout(this);
        setContentView(layout);
        layout.setId(ROOT_CONTAINER_ID);

        //刷新界面
        getFragmentManager().beginTransaction().replace(ROOT_CONTAINER_ID,getFragment()).commit();
    }

    /**
     * 抽象方法，供子类实现
     * @return
     */
    protected abstract Fragment getFragment();
}
